package spring;

import com.数据结构.线性表.ArrayList;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.PathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.WritableResource;

import java.io.*;

/**
 * @Date 2021/4/7 13:57
 * @Author WangLinBao
 * @Description
 */
public class FileResourceExample {
    public static void main(String[] args) throws IOException {
        String filePath = "D:\\wlb\\concurrent-study\\src\\main\\resources\\11111.txt";
//        ArrayList<Object> objects = new ArrayList<>(10);
//        for (int i = 0; i < 10; i++) {
//            objects.add(null);
//        }
//        objects.remove(10);
//        System.out.println(objects.get(0));

        ArrayList arrayList = new ArrayList(10);
        for (int i = 0; i < 20; i++) {
            arrayList.add(i);
        }

        for (int i = 0; i < 20; i++) {
            System.out.println("i = " + arrayList.get(i));
        }

        for (int i = 0; i < 10;i++) {
            arrayList.remove(10);
        }

        for (int i = 0; i < 10; i++) {
            System.out.println("i222 = " + arrayList.get(i));
        }


        //使用系统文件路径方式加载文件
//        WritableResource res1 = new PathResource(filePath);
//
//        //使用类路径方式加载文件
//        Resource res2 = new ClassPathResource("11111.txt");
//
//        //使用writableResource接口写资源文件
//        OutputStream stream1 = res1.getOutputStream();
//        stream1.write("hello".getBytes());
//        stream1.close();
//
//        //使用Resource接口读资源文件
//        InputStream ins1 = res1.getInputStream();
//        InputStream ins2= res2.getInputStream();
//        ByteArrayOutputStream baos = new ByteArrayOutputStream();
//        int i;
//        while ((i = ins1.read())!=-1){
//            baos.write(i);
//        }
//        System.out.println(baos.toString());
//
//        System.out.println("res1:"+res1.getFilename());
//        System.out.println("res2:"+res2.getFilename());


    }
}
